//# sourceURL=welcome.js
layui.element.on('tab(login-user-tabs)', function () {
    var currPage = 1;
    var searchJob_fn = {
        initRender: function () {
            layui.table.render({
                id: 'searchJobTableId',
                elem: '#searchJob-table',
                url: '/inviteCompanyJob/homePage/list',
                height: 'full-170',
                page: true,
                limits: cmsUtils.getLimits(),
                limit: cmsUtils.getLimit(),
                cols:[[
                    {title: '<b>序号</b>',type: 'numbers',align: 'center',width: 80},
                    {title: '<b>公司名称</b>',field: 'companyName'},
                    {title: '<b>职位</b>',field: 'jobTitleValue'},
                    {title: '<b>薪资</b>',field: 'salary'},
                    {title: '<b>学历要求</b>',field: 'eduRequireValue',width: 180},
                    {title: '<b>年龄要求</b>',field: 'workAgeRequire',width: 180},
                    {title: '<b>创建时间</b>',field: 'createDate',align: 'center',width: 160},
                    {title: '<b>操作选项</b>', width: 160, align: 'center', toolbar: '#searchJob-toolbar'}
                ]],
                done: function (res, curr, count) {
                    currPage = curr;
                    layui.form.render('select');
                    $('#searchJob').attr('hasRender', true);
                }
            });
        },
        reload: function (page) {
            layui.table.reload('searchJobTableId', {
                page:{
                    curr: page ? page : currPage
                }
            });
        },
        refreshList: function () {
            if ($('#searchJob')[0]) {
                searchJob_fn.reload(currPage);
            }
        },
        resetSearch: function () {
            layui.form.render('select');
            searchJob_fn.reload(1);
        }
    }

    if (!$('#searchJob').attr('hasRender')) {
        searchJob_fn.initRender();
        // 监听当前Tab页点击
        $(this).bind('tabClick', function () {
            searchJob_fn.refreshList();
        });
        // 搜索
        $('#searchJob-search-btn').click(function () {
            searchJob_fn.reload(1);
        });
        // 重置
        $('#searchJob-refresh-btn').click(function () {
            searchJob_fn.resetSearch();
        });
    }

    // 工具条监听
    layui.table.on('tool(searchJob-table)', function (obj) {
        switch (obj.event) {
            case 'edit':
                cmsUtils.addContentTab('searchJobDetail', '职位-详情', '/piger/searchJobDetail.html', {
                    id: obj.data.id,
                    list_fn: searchJob_fn
                });
                break;
            default:
                break;
        }
    });
});